#!/bin/sh
# This shell script used to cross compile file command for fl2440
# Before excute this shell script, please download the source code to here first.
# Download Address: Download: ftp://ftp.astron.com/pub/file/file-5.04.tar.gz

APP_NAME=file-5.04
PATCH_FILE=./patch/fl2440-$APP_NAME.patch
PACK_SUFFIX=tar.gz

if [ ! -d ${APP_NAME} ] ; then
   if [ -f ${APP_NAME}.${PACK_SUFFIX} -a -f $PATCH_FILE ] ; then
        echo "==================================================="
        echo "+           Decompress $APP_NAME now...            "
        echo "==================================================="
        rm -rf ${APP_NAME}
        tar -xzf ${APP_NAME}.${PACK_SUFFIX}
        
        echo "===================================================" 
        echo "+         Patching and build now...                " 
        echo "===================================================" 
        patch -p0 < ${PATCH_FILE}
  else 
          echo "==========================================================================" 
          echo "+       ERROR: Missing $APP_NAME Source Code Packet!                      " 
          echo "+ Plese download ${APP_NAME}.${PACK_SUFFIX} to here and try again! " 
          echo "+ Download: ftp://ftp.astron.com/pub/file/file-5.04.tar.gz " 
          echo "===========================================================================" 
          exit; 
  fi 
fi

cd $APP_NAME && sh build.sh

